﻿@model Gtkj.CMS.Model.Customer
@{
    ViewBag.Title = "修改客户";
    Layout = "~/Views/Shared/Master.cshtml";
}


<div class="page-content-wrapper">
    <!-- BEGIN CONTENT BODY -->
    <div class="page-content">
        <!-- BEGIN PAGE HEADER-->
        <div class="page-bar">
            <ul class="page-breadcrumb">
                <li>
                    <a href="/Home/Main">首页</a>
                    <i class="fa fa-angle-double-right"></i>
                </li>
                <li>
                    <span>修改客户</span>
                </li>
            </ul>
        </div>
        <h3 class="page-title">
            修改客户<span><a class="btn btn-success " href="javascript:;" onclick="history.go(-1);"><span class="icon-action-undo" aria-hidden="true" style="float:left; margin-top:3px; margin-right:4px"></span> 返回</a></span>
        </h3>
        <!-- BEGIN PAGE TITLE-->
        <div class="portlet light bordered">
            <div class="portlet-title">
                <div class="caption"><i class="icon-settings font-yellow-casablanca"></i><span class="caption-subject bold font-yellow-casablanca">修改客户信息</span></div>
            </div>
            <!--添加代码开始-->
            <div class="portlet-body form">
                <!-- BEGIN FORM-->
                <form action="#" id="AddOrderForm" method="post" class="form-horizontal layui-form">
                    @Html.HiddenFor(e=>e.Id)
                    @Html.HiddenFor(e=>e.Whos)
                    <div class="form-body">

                        <div class="form-group">
                            <label class="control-label col-md-3">
                                客户名称<span class="required"> * </span>
                            </label>
                            <div class="col-md-4">
                                <input type="text" name="Name" id="Name" value="@Model.Name" data-required="1" lay-verify="required" class="form-control" />
                            </div>
                        </div>
                        <div class="form-group">
                            <label class="control-label col-md-3">
                                客户手机号<span class="required"> * </span>
                            </label>
                            <div class="col-md-4">
                                <input type="text" name="Phone" id="Phone" data-required="1" value="@Model.Phone" lay-verify="required" class="form-control" />
                            </div>
                        </div>
                        <div class="form-group">
                            <label class="control-label col-md-3">
                                性别<span class="required"> * </span>
                            </label>
                            <div class="col-md-4">
                                @Html.CheckBoxFor(e => e.Sex, new { @data_size = "small", @id = "Sex", @class = "make-switch", @data_on_text = "男", data_off_text = "女" })
                                @*<input type="checkbox" data-size="small" name="Sex" id="Sex" class="make-switch" checked data-on-text="男" data-off-text="女">*@
                            </div>
                        </div>
                        <div class="form-group">
                            <label class="control-label col-md-3">
                                年龄<span class="required"> * </span>
                            </label>
                            <div class="col-md-4">
                                <input type="text" name="Age" data-required="1" id="Age" value="@Model.Age" lay-verify="required|number" class="form-control" />
                            </div>
                        </div>
                        <div class="form-group">
                            <label class="control-label col-md-3">
                                客户地址<span class="required"> * </span>
                            </label>
                            <div class="col-md-4">
                                <input type="text" name="Address" data-required="1" id="Address" value="@Model.Address" lay-verify="required" class="form-control" />
                            </div>
                        </div>
                        <div class="form-group">
                            <label class="control-label col-md-3">
                                客户等级<span class="required"> * </span>
                            </label>
                            <div class="col-md-4">
                                <select class="bs-select form-control" id="Stars" name="Stars" data-width="125px" style="display:block;">
                                    <option value="暂无">请选择</option>
                                    <option value="一级">一级</option>
                                    <option value="二级">二级</option>
                                    <option value="三级">三级</option>
                                    <option value="四级">四级</option>
                                    <option value="五级">五级</option>
                                </select>
                            </div>
                        </div>

                        <div class="form-group">
                            <label class="control-label col-md-3">
                                详情
                            </label>
                            <div class="col-md-4">
                                <textarea id="Details" name="Details" class="form-control" placeholder="输入详情 ..." rows="4">@Model.Details</textarea>
                            </div>
                        </div>
                    </div>

                    <div class="form-actions">
                        <div class="row">
                            <div class="col-md-offset-3 col-md-9">
                                @*<a href="#" class="btn btn-primary"> <span class="glyphicon glyphicon-ok"> </span> 提交 </a>*@
                                <button type="button" lay-submit class="btn btn-primary" onclick="AddOrderOn();"><span class="glyphicon glyphicon-ok"> </span> 提交</button>
                                <button type="button" class="btn default" onclick="history.go(-1);"><span class="glyphicon glyphicon-remove"> </span> 取消</button>
                            </div>
                        </div>
                    </div>
                </form>
                <!-- END FORM-->
            </div>
        </div>
        <!--添加代码结束-->
    </div>
</div>
<script>
    $(function() {
        var selected = "@Model.Stars";
        $("#Stars option").each(function (index, item) {
            if ($(item).text() == selected) {
                $(item).attr("selected","selected");
            }
        });
    });
    function AddOrderOn() {
        $.ajax({
            url: "/Home/UpdateCustomerOn",
            type: "post",
            data: $("#AddOrderForm").serialize(),
            success: function (result) {
                if (result.success) {
                    location.href = "/Home/CustomerList";
                } else {
                    if (!result.requied) {
                        layer.msg(result.msg);
                    }
                }
            }
        });
    }
</script>
